﻿using log4net;
using log4net.Core;
using ShareHelper;
using System;
using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private TimerEx TimerEx;
        private void Form1_Load(object sender, EventArgs e)
        {

            Console.WriteLine(BitConverter.ToUInt16(HexHelper.HexStrToByte("5c 00"), 0));
            Console.WriteLine(HexHelper.HexStrToByte("01 04 5C 00 46 00 DD 00 D7 00 E2 01 F3 01 F3 01 F3 00 DD 00 D6 00 E2 01 F3 01 F3 01 F3 08 A4 08 A6 08 A1 00 0A 00 0C 00 0F 01 F4 01 F4 01 F4 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 03 00 02 00 03 00 01 00 00 00 00 01 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 5E 00 07 10 75 ").Length);
            TimeSpan span = (TimeSpan)(DateTime.UtcNow - new DateTime(0x7b2, 1, 1, 0, 0, 0, 0));
            int totalSeconds = (int)span.TotalSeconds;
            var a = DateTime.UtcNow;
            ;
            var lLLog = new Log(textBox1) { Level = Level.Info };
            TimerEx = new TimerEx(1000);
            TimerEx.Elapsed += TimerEx_Elapsed;
            TimerEx.Start();


            ;
        }

        private void TimerEx_Elapsed(object state)
        {
            TimerEx.Dispose();
            Log.Info($"{DateTime.Now}");
            int.Parse("zzzzz");
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            var a = Log.LogLevel;
            var aaa = TaskHelper.Run(() => { throw new Exception(""); });
            var cvcc = TaskHelper.Run(() => { int.Parse("zzzzz"); });

            var log = LogManager.GetLogger("Test");
            var data = new byte[] { 88, 205, 215 };
            var ccccd = data.Select(ccc => ccc.ToString("X"));
            Console.WriteLine(string.Join(" ", ccccd));
            var str = string.Format("{0}", ccccd);
            log.ErrorFormat("{0}", data);
            log.InfoFormat("{0:X00}", data);
            log.Debug("22111debug测试");
            log.Info("22111debug测试");
            log.Info("22111debug测试");
            log.Error("22111Error测试");
        }


    }
}